package com.sykj.util;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName TemplateMessageHelper
 * @Description TODO 模板消息帮助类
 * @Author vains
 * @Date 2019/7/1 11:16
 * @Version 1.0
 **/
@NoArgsConstructor
@Data
public class TemplateMessageHelper {

    /**
     * touser : OPENID
     * template_id : ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY
     * url : http://weixin.qq.com/download
     * data : {"orderAmount":{"value":"恭喜你购买成功！"},"buyerName":{"value":"巧克力"},"buyerAddress":{"value":"39.8元"},"orderId":{"value":"2014年9月22日"},"createTime":{"value":"欢迎再次购买！"}}
     */

    /**
     * 目标用户openid
     */
    private String touser;
    /**
     * 消息模板id
     */
    private String template_id;
    /**
     * 点击之后跳转的url
     */
    private String url;

    /**
     * 模板中的数据
     */
    private DataBean data;

    @NoArgsConstructor
    public static class DataBean {
        public OrderAmountBean getOrderAmount() {
            return orderAmount;
        }

        public void setOrderAmount(BigDecimal orderAmount) {
            OrderAmountBean orderAmountBean = new OrderAmountBean();
            orderAmountBean.setValue(String.valueOf(orderAmount.doubleValue()));
            this.orderAmount = orderAmountBean;
        }

        public BuyerNameBean getBuyerName() {
            return buyerName;
        }

        public void setBuyerName(String buyerName) {
            BuyerNameBean buyerNameBean = new BuyerNameBean();
            buyerNameBean.setValue(buyerName);
            this.buyerName = buyerNameBean;
        }

        public BuyerAddressBean getBuyerAddress() {
            return buyerAddress;
        }

        public void setBuyerAddress(String buyerAddress) {
            BuyerAddressBean buyerAddressBean = new BuyerAddressBean();
            buyerAddressBean.setValue(buyerAddress);
            this.buyerAddress = buyerAddressBean;
        }

        public OrderIdBean getOrderId() {
            return orderId;
        }

        public void setOrderId(String orderId) {
            OrderIdBean orderIdBean = new OrderIdBean();
            orderIdBean.setValue(orderId);
            this.orderId = orderIdBean;
        }

        public CreateTimeBean getCreateTime() {
            return createTime;
        }

        public void setCreateTime(Date createTime) {
            CreateTimeBean createTimeBean = new CreateTimeBean();
            createTimeBean.setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime));
            this.createTime = createTimeBean;
        }

        /**
         * orderAmount : {"value":"10.0元"}
         * buyerName : {"value":"vains"}
         * buyerAddress : {"value":"xx市xx区xx号"}
         * orderId : {"value":"142225548"}
         * createTime : {"value":"2019-07-01 15:11:15"}
         */

        private OrderAmountBean orderAmount;
        private BuyerNameBean buyerName;
        private BuyerAddressBean buyerAddress;
        private OrderIdBean orderId;
        private CreateTimeBean createTime;

        @NoArgsConstructor
        @Data
        public static class OrderAmountBean {
            /**
             * value : 恭喜你购买成功！
             */

            private String value;
        }

        @NoArgsConstructor
        @Data
        public static class BuyerNameBean {
            /**
             * value : 巧克力
             */

            private String value;
        }

        @NoArgsConstructor
        @Data
        public static class BuyerAddressBean {
            /**
             * value : 39.8元
             */

            private String value;
        }

        @NoArgsConstructor
        @Data
        public static class OrderIdBean {
            /**
             * value : 2014年9月22日
             */

            private String value;
        }

        @NoArgsConstructor
        @Data
        public static class CreateTimeBean {
            /**
             * value : 欢迎再次购买！
             */

            private String value;
        }
    }
}
